博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHPCMS快速建站系列之类别调用及类别显示页面
阅读量:4310 次
发布时间:2019-06-06

本文共 2991 字,大约阅读时间需要 9 分钟。

在需要调用类别的地方,比如列表页,首先写循环前面写上一句:

这句就是把类别缓存加载进来.

然后在循环里写:

这样就可以调用出来类别了.

不过链接暂时无效.因为还没有做好链接文件.后面会更新这个文件的.

更新时间: 2011年1月3日1:12:01
类别链接页面:
新增一个 type.html 文件放到 phpcms\templates\default\content\ 下:
该文件代码如下:

{template "content","header"}
首页
> {catpos($catid)} 类别:
{$TYPE[$typeid][name]} 总共有 {$total} 条记录
    {loop $datas $r}
  • {date('Y-m-d H:i:s',$r[inputtime])}·{$r[title]}
  • {if $n%5==0}
  • {/if}{/loop}
{$pages}
频道总排行
{pc:content action="hits" catid="$catid" num="10" order="views DESC"}
{/pc}
{template "content","footer"}

 

新增一个 type.php 文件到 phpcms\modules\content\下,该文件代码如下:

db = pc_base::load_model('content_model');}/** * 按照模型搜索 */public function init() { if(!isset($_GET['catid'])) showmessage(L('missing_part_parameters')); $catid = intval($_GET['catid']); $siteids = getcache('category_content','commons'); $siteid = $siteids[$catid]; $this->categorys = getcache('category_content_'.$siteid,'commons'); if(!isset($this->categorys[$catid])) showmessage(L('missing_part_parameters')); if(isset($_GET['info']['catid']) && $_GET['info']['catid']) { $catid = intval($_GET['info']['catid']); } else { $_GET['info']['catid'] = 0; } if(isset($_GET['typeid']) && trim($_GET['typeid']) != '') { $typeid = intval($_GET['typeid']); } else { showmessage(L('illegal_operation')); } $TYPE = getcache('type_content','commons'); $modelid = $this->categorys[$catid]['modelid']; $modelid = intval($modelid); if(!$modelid) showmessage(L('illegal_parameters')); $CATEGORYS = $this->categorys; $siteid = $this->categorys[$catid]['siteid']; $siteurl = siteurl($siteid); $this->db->set_model($modelid); $page = $_GET['page']; $datas = $infos = array(); $infos = $this->db->listinfo("`typeid` = '$typeid'",'id DESC',$page,20);//读取整个模型下同类别文章 //$infos = $this->db->listinfo("`typeid` = '$typeid' AND catid = '$catid'",'id DESC',$page,20);//仅仅读取当前栏目下的同类别文章,如果要启用此模式,请去掉上一行代码并将本行开头的// 两斜杠去掉. $total = $this->db->number; if($total>0) { $pages = $this->db->pages; foreach($infos as $_v) { if(strpos($_v['url'],'://')===false) $_v['url'] = $siteurl.$_v['url']; $datas[] = $_v; } } $SEO = seo($siteid, $catid, $TYPE[$typeid]['name'],$TYPE[$typeid]['description'],$TYPE[$typeid]['name'].'类别'); include template('content','type');}}?>

上面的链接即可生效.
需要注意的是:
  $infos = $this->db->listinfo("`typeid` = '$typeid'",'id DESC',$page,20);//读取整个模型下同类别文章
  //$infos = $this->db->listinfo("`typeid` = '$typeid' AND catid = '$catid' ",'id DESC',$page,20);//仅仅读取当前栏目下的同类别文章,如果要启用此模式,请去掉上一行代码并将本行开头的// 两斜杠去掉.

 

摘自:http://bbs.phpcms.cn/thread-243656-1-1.html

转载于:https://www.cnblogs.com/MY0101/p/6294043.html

你可能感兴趣的文章
《java编程思想》读书笔记(一)开篇&第五章(1)
查看>>
swift--调用系统单例实现打电话
查看>>
0038-算一算是一年中的第几天
查看>>
51nod 1094 【水题】
查看>>
虚拟机设置静态IP地址
查看>>
Oracle表或分区导出脚本
查看>>
Springboot上传文件出现MultipartException
查看>>
NHibernate错误:Could not compile the mapping document的解决
查看>>
PHP 之微信小程序支付封装
查看>>
Dynamics CRM SQL转化为FetchXML的在线转化工具
查看>>
Dynamics CRM2011 MspInstallAction failed when installing an Update Rollup
查看>>
找老鼠啊~亏了还是赚了?
查看>>
注意Hibernate4在开发当中的一些改变
查看>>
关于vue的源码调试
查看>>
003.第一个动画:绘制直线
查看>>
vc中的获取时间方式,struct time和time_t(转自百度空间)
查看>>
Civil 3D 中使用COM API导入DEM数据创建曲面
查看>>
spring注解
查看>>
springboot(十八):CORS方式实现跨域
查看>>
打码大致过程
查看>>